<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitepagealbum
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: Global.php 2011-05-05 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
class Sitepagealbum_Form_Admin_Global extends Engine_Form {
	
	public function init() {
		
		$this->setTitle ( 'Global Settings' )->setDescription ( 'These settings affect all members in your community.' );
		
		$this->addElement ( 'Text', 'sitepagealbum_lsettings', array ('label' => 'Enter License key', 'description' => "Please enter your license key that was provided to you when you purchased this plugin. If you do not know your license key, please contact the Support Team of SocialEngineAddOns from the Support section of your Account Area.(Key Format: XXXXXX-XXXXXX-XXXXXX )", 'value' => Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'sitepagealbum.lsettings' ) ) );
		
		$global_settings_file = APPLICATION_PATH . '/application/settings/general.php';
		if (file_exists ( $global_settings_file )) {
			$generalConfig = include $global_settings_file;
		} else {
			$generalConfig = array ();
		}
		if ((! empty ( $generalConfig ['environment_mode'] )) && ($generalConfig ['environment_mode'] != 'development')) {
			$this->addElement ( 'Checkbox', 'environment_mode', array ('label' => 'Your community is currently in "Production Mode". We recommend that you momentarily switch your site to "Development Mode" so that the CSS of this plugin renders fine as soon as the plugin is installed. After completely installing this plugin and visiting few pages of your site, you may again change the System Mode back to "Production Mode" from the Admin Panel Home. (In Production Mode, caching prevents CSS of new plugins to be rendered immediately after installation.)', 'description' => 'System Mode', 'value' => 1 ) );
		} else {
			$this->addElement ( 'Hidden', 'environment_mode', array ('order' => 990, 'value' => 0 ) );
		}
		
		if (Engine_Api::_ ()->sitepage ()->hasPackageEnable ()) {
			$this->addElement ( 'Checkbox', 'include_in_package', array ('label' => 'Enable albums module for the default package that was created upon installation of the "Directory / Pages Plugin". If enabled, Albums App will also be enabled for the Pages created so far under the default package.', 'description' => 'Enable Albums Module for Default Package', 'value' => 1 ) );
		}
		
		$this->addElement ( 'Button', 'submit_lsetting', array ('label' => 'Activate Your Plugin Now', 'type' => 'submit', 'ignore' => true ) );
		
		$this->addElement ( 'Radio', 'sitepagealbum_photolightbox_show', array ('label' => 'Advanced Lightbox Display', 'description' => 'Do you want to enable advanced lightbox display for album photos? (This setting will be applied at all places where photos of pages are viewed by users.)', 'multiOptions' => array (1 => 'Yes', 0 => 'No' ), 'onclick' => 'showphotolightboxBg(this.value); showphotolightboxFont(this.value); lightbox_activityfeed_edit(this.value);', 'value' => Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'sitepagealbum.photolightbox.show', 1 ) ) );
		
		$this->addElement ( 'Text', 'sitepagealbum_photolightbox_bgcolor', array ('decorators' => array (array ('ViewScript', array ('viewScript' => '_formImagerainbowLightBoxBg.tpl', 'class' => 'form element' ) ) ) ) );
		
		$this->addElement ( 'Text', 'sitepagealbum_photolightbox_fontcolor', array ('decorators' => array (array ('ViewScript', array ('viewScript' => '_formImagerainbowLightBoxFont.tpl', 'class' => 'form element' ) ) ) ) );
		
		$this->addElement ( 'Radio', 'sitepagealbum_photolightbox_activityedit', array ('label' => 'Activity Feed Text template file modification', 'description' => 'Do you want the Activity Feed Text template file to be overwritten automatically for the minor addition to it, or do you want to make the change to it manually? (This is required to enable Advanced Lightbox Display for the album photos which gets diplayed in the Activity Feed on the Page Profile.)', 'multiOptions' => array (1 => 'Yes, automatically overwrite the Activity Feed Text template file.', 0 => 'No, I will manually modify the file. (Click on this radio button to see the change that needs to be made.)' ), 'value' => Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'sitepagealbum.photolightbox.activityedit', 0 ), 'onclick' => 'show_activitymanual(this.value)' ) );
		
		$this->addElement ( 'Dummy', 'sitepagealbum_show_activitymanual', array ('description' => 'To display the page album photos which comes in the activity feed on Page Profile in Advanced Lightbox, follow the steps given below:<br /><br />
Step 1: Open this file: "/application/modules/Activity/views/scripts/_activityText.tpl".<br />
				Step 2: Now, search the block of code given below at line number 148-151(approx).<br /><br />
				<div class="code">
					&lt;?php elseif( $attachment->meta->mode == 2 ): // Thumb only type actions ?&gt;<br />
										&lt;div class="feed_attachment_photo"&gt;<br />
											&lt;?php echo $this->htmlLink($attachment->item->getHref(), $this->itemPhoto($attachment->item, \'thumb.normal\', $attachment->item->getTitle()), array(\'class\' => \'feed_item_thumb\')) ?&gt;<br />
										&lt;/div&gt;
				</div><br />
				Step 3: Replace the old code found above with the new block of code given below:<br /><br />
				<div class="code" >
					&lt;?php elseif( $attachment->meta->mode == 2 ): // Thumb only type actions ?&gt;<br />
                  &lt;div class="feed_attachment_photo"&gt;<br />
										&lt;?php  if($sitepageAlbumEnable && $attachment->item->getType() == "sitepage_photo"  &&  Engine_Api::_()->sitepage()->canShowPhotoLightBox()):?&gt;<br />					
											&lt;a class="feed_item_thumb" href="&lt;?php echo $attachment->item->getHref() ?&gt;" onclick=\'openLightBox("&lt;?php echo $attachment->item->getPhotoUrl()?&gt;","&lt;?php echo Engine_Api::_()->sitepage()->getHreflink($attachment->item) ?&gt;");return false;\' &gt; &lt;?php echo $this->itemPhoto($attachment->item, \'thumb.normal\', $attachment->item->getTitle()) ?&gt;&lt;/a&gt;<br />
											&lt;?php else: ?&gt;<br />
												&lt;?php echo $this->htmlLink($attachment->item->getHref(), $this->itemPhoto($attachment->item, \'thumb.normal\', $attachment->item->getTitle()), array(\'class\' => \'feed_item_thumb\')) ?&gt;<br />
										&lt;?php endif; ?&gt;<br />
                  &lt;/div&gt;
				</div><br />
				Step 4: Now, search for the below line of code at the top of this file at line number 14(approx).<br /><br />
				<div class="code" >
					&lt;?php if( empty($this->actions) ) {
				</div><br />
						Step 5: Place the block of code given below just before the line of code mentioned above at the top of this file.<br /><br />
				<div class="code" >
					&lt;?php $sitepageAlbumEnable = Engine_Api::_()->getDbtable(\'modules\', \'core\')->isModuleEnabled(\'sitepagealbum\'); ?&gt;<br />
										&lt;?php if(Engine_Api::_()->sitepage()->canShowPhotoLightBox() && $sitepageAlbumEnable):<br />
											include_once APPLICATION_PATH . \'/application/modules/Sitepagealbum/views/scripts/_lightboxImage.tpl\';<br />
										endif; ?&gt;</div><br />' ) );
		$this->getElement ( 'sitepagealbum_show_activitymanual' )->getDecorator ( 'Description' )->setOptions ( array ('placement', 'APPEND', 'escape' => false ) );
		
		$this->addElement ( 'Text', 'sitepagealbum_truncation_limit', array ('label' => 'Title Truncation Limit', 'allowEmpty' => false, 'maxlength' => '3', 'required' => true, 'description' => 'What maximum limit should be applied to the number of characters in the title of items in the widgets? (Enter a number between 1 and 999. Titles having more characters than this limit will be truncated. Complete titles will be shown on mouseover.)', 'value' => Engine_Api::_ ()->getApi ( 'settings', 'core' )->getSetting ( 'sitepagealbum.truncation.limit', 13 ), 'validators' => array (array ('Int', true ), array ('GreaterThan', true, array (0 ) ) ) ) );
		
		$this->addElement ( 'Button', 'submit', array ('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true ) );
	}

}

?>